/**
 *
 */
package com.hybris.msig.paymentgateway;

import de.hybris.platform.converters.impl.AbstractPopulatingConverter;
import de.hybris.platform.util.Config;

import java.util.Arrays;

import javax.servlet.http.HttpServletRequest;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.hybris.msig.paymentgateway.adapters.enets.EnetsGatewayAdapter;
import com.hybris.msig.paymentgateway.adapters.telemoney.TelemoneyGatewayAdapter;
import com.hybris.msig.paymentgateway.data.PaymentResponseData;
import com.hybris.msig.paymentgateway.model.PaymentResponseModel;
import com.hybris.msig.paymentgateway.populators.MsigPaymentResponsePopulator;
import com.hybris.msig.paymentgateway.populators.TelemoneyPaymentCallbackPopulator;


/**
 * @author i313922
 *
 */
@Configuration
public class PaymentGatewayConfiguration
{
	@Bean
	public TelemoneyGatewayAdapter telemoneyGatewayAdapter()
	{
		final String requestPage = Config.getParameter("msigpaymentgateway.telemoney.requestpage");
		final String returnUrl = Config.getParameter("msigpaymentgateway.telemoney.returnurl");
		final String statuUrl = Config.getParameter("msigpaymentgateway.telemoney.statusurl");
		final String mid = Config.getParameter("msigpaymentgateway.telemoney.mid");
		final String clientStatusPageUrl = Config.getParameter("msigpaymentgateway.telemoney.clientstatuspageurl");
		final TelemoneyGatewayAdapter teleMoneyAdapter = new TelemoneyGatewayAdapter();
		teleMoneyAdapter.setMid(mid);
		teleMoneyAdapter.setRequestPage(requestPage);
		teleMoneyAdapter.setReturnUrl(returnUrl);
		teleMoneyAdapter.setStatusUrl(statuUrl);
		teleMoneyAdapter.setClientStatusPageUrl(clientStatusPageUrl);
		return teleMoneyAdapter;
	}

	@Bean
	public EnetsGatewayAdapter eNetsGatewayAdapter()
	{
		final String requestPage = Config.getParameter("msigpaymentgateway.enets.requestpage");
		final String returnUrl = Config.getParameter("msigpaymentgateway.enets.returnurl");
		final String statuUrl = Config.getParameter("msigpaymentgateway.enets.statusurl");
		final String mid = Config.getParameter("msigpaymentgateway.enets.mid");
		final String clientStatusPageUrl = Config.getParameter("msigpaymentgateway.enets.clientstatuspageurl");
		final EnetsGatewayAdapter eNetsGatewayAdapter = new EnetsGatewayAdapter();
		eNetsGatewayAdapter.setMid(mid);
		eNetsGatewayAdapter.setRequestPage(requestPage);
		eNetsGatewayAdapter.setReturnUrl(returnUrl);
		eNetsGatewayAdapter.setStatusUrl(statuUrl);
		eNetsGatewayAdapter.setClientStatusPageUrl(clientStatusPageUrl);
		return eNetsGatewayAdapter;
	}

	@Bean
	public AbstractPopulatingConverter msigPaymentResponseConverter()
	{
		final AbstractPopulatingConverter<PaymentResponseModel, PaymentResponseData> converter = new AbstractPopulatingConverter()
		{
			//Create converter
		};
		converter.setTargetClass(PaymentResponseData.class);
		converter.setPopulators(Arrays.asList(new MsigPaymentResponsePopulator()));
		return converter;
	}

	@Bean
	public AbstractPopulatingConverter teleMoneyPaymentCallbackConverter()
	{
		final AbstractPopulatingConverter<HttpServletRequest, PaymentResponseData> converter = new AbstractPopulatingConverter()
		{
			//Create converter
		};
		converter.setTargetClass(PaymentResponseData.class);
		converter.setPopulators(Arrays.asList(new TelemoneyPaymentCallbackPopulator()));
		return converter;
	}
}
